﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_agent_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (null != Request.QueryString["id"])
            {
                CAgent a = new CAgent();
                DataRow r = a.ReadAgent(Convert.ToInt32(Request.QueryString["id"].ToString()));
                if (null != r)
                {
                    this.tbTitle.Text = r["title"].ToString();
                    this.tbUserName.Text = r["username"].ToString();
                    this.tbPwd.Text = r["userpwd"].ToString();
                }
            }
        }

    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (null != Request.QueryString["id"])
        {
            //更新
            CAgent a = new CAgent();
            a.Update(Convert.ToInt32(Request.QueryString["id"].ToString()), this.tbTitle.Text,this.tbUserName.Text,this.tbPwd.Text);
        }
        else
        {
            //添加
            CAgent a = new CAgent();
            a.Add(this.tbTitle.Text, this.tbUserName.Text,this.tbPwd.Text);
        }
        ScriptManager.RegisterClientScriptBlock(Page, upEdit.GetType(), "", "alert('操作完成！');", true);
        //ScriptManager.RegisterClientScriptBlock(Page, upEdit.GetType(), "", "alert('" + this.tbContent.Text + "');", true);
    }
    protected void btnOk1_Click(object sender, EventArgs e)
    {
        //妈的，为什么要提交两次才能获取到内容，耽误时间啊，用户体验啊，Shit!!!
    }
}